package com.atmilan.quartz.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.atmilan.quartz.mapper.StoreProductCouponLuxuryMapper;
import com.atmilan.quartz.model.entity.crmeb.StoreProductCoupon;
import com.atmilan.quartz.service.IStoreProductCouponLuxuryService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
* @description StoreProductCouponServiceImpl 接口实现
* @date 2020-08-07
*/
@Service
public class StoreProductCouponLuxuryServiceImpl extends ServiceImpl<StoreProductCouponLuxuryMapper, StoreProductCoupon> implements IStoreProductCouponLuxuryService {

    /**
     *
     * @param productId 产品id
     */
    @Override
    public boolean deleteByProductId(Integer productId) {
        LambdaQueryWrapper<StoreProductCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(StoreProductCoupon::getProductId, productId);
        return remove(lambdaQueryWrapper);
    }

    /**
     *
     * @param storeProductCoupons 优惠券关联信息
     * @return
     */
    @Override
    public void saveCoupons(List<StoreProductCoupon> storeProductCoupons) {
        for (StoreProductCoupon storeProductCoupon : storeProductCoupons) {
            save(storeProductCoupon);
        }
    }

    /**
     * 根据商品id获取已关联优惠券信息
     * @param productId 商品id
     * @return 已关联优惠券
     */
    @Override
    public List<StoreProductCoupon> getListByProductId(Integer productId) {
        LambdaQueryWrapper<StoreProductCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(StoreProductCoupon::getProductId, productId);
        return list(lambdaQueryWrapper);
    }
    
}
